/*     */ package com.zimbra.cs.server;
/*     */ 
/*     */ import com.zimbra.cs.security.sasl.SaslFilter;
/*     */ import java.io.OutputStream;
/*     */ import java.net.InetSocketAddress;
/*     */ import javax.security.sasl.SaslServer;
/*     */ import org.apache.mina.core.filterchain.IoFilterChain;
/*     */ import org.apache.mina.core.session.IoSession;
/*     */ import org.apache.mina.core.session.IoSessionConfig;
/*     */ import org.apache.mina.filter.ssl.SslFilter;
/*     */ import org.apache.mina.filter.ssl.ZimbraSslFilter;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class NioConnection
/*     */ {
/*     */   private final NioServer server;
/*     */   private final IoSession session;
/*     */   private final OutputStream out;
/*     */   private final InetSocketAddress remoteAddress;
/*     */   private ZimbraSslFilter tlsSslFilter;
/*     */   
/*     */   NioConnection(NioServer server, IoSession session)
/*     */   {
/*  38 */     this.server = server;
/*  39 */     this.session = session;
/*  40 */     this.remoteAddress = ((InetSocketAddress)session.getRemoteAddress());
/*  41 */     this.out = new NioOutputStream(session, server.getConfig().getWriteChunkSize(), server.getConfig().getNioMaxWriteQueueSize(), server.getConfig().getNioMaxWriteQueueDelay());
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public long getId()
/*     */   {
/*  49 */     return this.session.getId();
/*     */   }
/*     */   
/*     */   public OutputStream getOutputStream() {
/*  53 */     return this.out;
/*     */   }
/*     */   
/*     */   public NioServer getServer() {
/*  57 */     return this.server;
/*     */   }
/*     */   
/*     */   public InetSocketAddress getLocalAddress() {
/*  61 */     return (InetSocketAddress)this.session.getServiceAddress();
/*     */   }
/*     */   
/*     */   public InetSocketAddress getRemoteAddress() {
/*  65 */     return this.remoteAddress;
/*     */   }
/*     */   
/*     */   public void setMaxIdleSeconds(int secs) {
/*  69 */     this.session.getConfig().setBothIdleTime(secs);
/*     */   }
/*     */   
/*     */   public boolean isTlsStartedIfNecessary() {
/*  73 */     return (this.tlsSslFilter == null) || (this.tlsSslFilter.isSslHandshakeComplete(this.session));
/*     */   }
/*     */   
/*     */   public void startTls() {
/*  77 */     this.tlsSslFilter = this.server.newSSLFilter();
/*  78 */     this.session.getFilterChain().addFirst("ssl", this.tlsSslFilter);
/*  79 */     this.session.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.valueOf(true));
/*     */   }
/*     */   
/*     */   public void startSasl(SaslServer sasl) {
/*  83 */     SaslFilter filter = new SaslFilter(sasl);
/*  84 */     this.session.getFilterChain().addFirst("sasl", filter);
/*  85 */     this.session.setAttribute(SaslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.valueOf(true));
/*     */   }
/*     */   
/*     */   public void send(Object obj) {
/*  89 */     this.session.write(obj);
/*     */   }
/*     */   
/*     */   public long getScheduledWriteBytes() {
/*  93 */     return this.session.getScheduledWriteBytes();
/*     */   }
/*     */   
/*     */   public boolean isOpen() {
/*  97 */     return this.session.isConnected();
/*     */   }
/*     */   
/*     */   public void close() {
/* 101 */     this.session.close(false);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/server/NioConnection.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */